
#include "../../Command.h"

#include "../../engine.h"

#include "../../User.h"

#include "../../NLogic/Battle.h"


namespace ProjectZ { namespace NCommand {

void Command::CS_REQ_PK_MAP_INFO(User * pUser, ::Network::Packet * pPacket)
{
	NLogic::Space * pSpace = pUser->GetSpace();
	if ( pSpace == NULL )
	{
		NLogic::NFunction::SendExceptionNoSpace(pUser);
		DEBUGLOG("%s pSpace == NULL", __FUNCTION__);
		return;
	}

	STRESSLOG("%s", __FUNCTION__);

	PREPARE_PACKET;

	DEBUGLOG("GID \t%d CS_REQ_PK_MAP_INFO", pUser->GetUserSeq());

	NLogic::Battle * pBattleRoyalBattle = pUser->GetBattleRoyalBattle();
	if (NULL == pBattleRoyalBattle)
	{
		::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
		*pAck << static_cast<uint16_t>(0);	// 입장할 맵ID	(123)
		*pAck << static_cast<uint16_t>(0);	// 입장 좌표X(1P: 242, 2P: 908, 3P: 590, 4P: 590)
		*pAck << static_cast<uint16_t>(0);	// 입장 좌표Y(1P: 529,	2P: 529, 3P: 332, 4P: 714)
		*pAck << static_cast<uint8_t>(0);	// 입장순서 1p = 0, 2p = 1, 3p = 2
		*pAck << static_cast<uint16_t>(0);	// 방향(1P:0, 2P:180, 3P: 90, 4P: 270)

		pAck->MakePacket(CMD_SC_REQ_PK_MAP_INFO);
		pUser->Send(pAck);
	}
	else
	{
		::Network::Packet * pAck = ::Network::GETPACKETPOOL()->SEND_NEW();
		*pAck << static_cast<uint16_t>(123);	// 입장할 맵ID	(123)
		*pAck << static_cast<uint16_t>(pUser->GetBattleRoyalBattle()->GetData().x);	// 입장 좌표X(1P: 242, 2P: 908, 3P: 590, 4P: 590)
		*pAck << static_cast<uint16_t>(pUser->GetBattleRoyalBattle()->GetData().y);	// 입장 좌표Y(1P: 529,	2P: 529, 3P: 332, 4P: 714)

		//if (pUser->GetBattleRoyalBattle()->GetData().x == 1824)
		{
			DEBUGLOG("GetBattleRoyalBattle %s x : %d y : %d GID : %d", __FUNCTION__, pUser->GetBattleRoyalBattle()->GetData().x, pUser->GetBattleRoyalBattle()->GetData().y, pUser->GetUserSeq());
		}

		*pAck << static_cast<uint8_t>(pUser->GetBattleRoyalBattle()->GetData()._inviteCount);	// 입장순서 1p = 0, 2p = 1, 3p = 2
		*pAck << static_cast<uint16_t>(pUser->GetBattleRoyalBattle()->GetData().degree);	// 방향(1P:0, 2P:180, 3P: 90, 4P: 270)

		pAck->MakePacket(CMD_SC_REQ_PK_MAP_INFO);
		pUser->Send(pAck);
	}
}

} /*NCommand*/ } /*ProjectZ*/

